<?php

use think\migration\Migrator;
use Phinx\Db\Adapter\MysqlAdapter;

class IntegralGoodsTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('integral_goods');
        $table->addColumn('sort','integer',array('limit' => MysqlAdapter::INT_REGULAR,'default' => 0, 'comment' => '排序'))->addIndex('sort');
        $table->addColumn('store_id','integer',array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '店铺id','default' => 0))->addIndex('store_id');
        $table->addColumn('integral_category_id','integer',array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '分类id'))->addIndex('integral_category_id');
        $table->addColumn('goods_name','string',array('limit' => 255,'comment' => '商品名称'));
        $table->addColumn('main_image','string',array('limit' => 255,'comment' => '商品主图'));
        $table->addColumn('goods_images','json',array('comment' => '商品图片'));
        $table->addColumn('goods_attr','json',array('comment' => '商品属性'));
        $table->addColumn('sell_low_price','decimal',array('precision'=> 10,'scale'=> 2,'comment' => '销售最低价','default' => 0.00));
        $table->addColumn('total_stock','integer',array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '总库存','default' => 0));
        $table->addColumn('exchange_low_integral','integer',array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '销售最低积分','default' => 0));
        $table->addColumn('exchange_people_num','integer',array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '兑换人数','default' => 0));
        $table->addColumn('status','boolean',array('limit' => 1, 'comment' => ' 0 下架 1 上架','default' => 0 ));
        $table->addTimestamps('create_time','update_time');
        $table->addSoftDelete('delete_time');
        $table->create();
    }
}
